package com.hopu.dy.service.impl;


import com.hopu.dy.mapper.LikeNoticeMapper;
import com.hopu.dy.pojo.LikeNotice;
import com.hopu.dy.service.ILikeNoticeService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LikeNoticeServiceImpl implements ILikeNoticeService {

    @Resource
    private LikeNoticeMapper likeNoticeMapper;

    @Override
    public void createLikeNotice(Long likerId, Long videoId) {
        // 从SecurityContext或Session中获取当前登录用户ID
        Long likedUserId = getCurrentUserId();

        LikeNotice notice = new LikeNotice();
        notice.setLikedUserId(likedUserId);
        notice.setLikerId(likerId);
        notice.setVideoId(videoId);
        notice.setCreateTime(new Date());

        likeNoticeMapper.insert(notice);
    }

    @Override
    public List<LikeNotice> getLikeNotices(Long likedUserId) {
        return likeNoticeMapper.selectByLikedUserId(likedUserId);
    }

    // 模拟获取当前登录用户ID（实际需替换为安全实现）
    private Long getCurrentUserId() {
        return 1L; // 示例值，实际需从Spring Security或Session获取
    }
}